package com.hdw.cms.dwr;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Service;

import com.hdw.cms.service.AttachmentService;
import com.hdw.cms.service.CmsLinkService;
import com.hdw.cms.service.GroupService;
import com.hdw.cms.service.IndexPicService;
import com.hdw.cms.service.IndexService;
import com.hdw.cms.service.TopicService;

//@RemoteProxy(name="dwrService")
@Service("dwrService")
public class DwrServiceImpl implements DwrService {

	@Resource(name = "groupService")
	private GroupService groupService;

	@Resource(name = "topicService")
	private TopicService topicService;

	@Resource(name = "attachmentService")
	private AttachmentService attachmentService;

	@Resource(name = "indexPicService")
	private IndexPicService indexPicService;

	@Resource(name = "cmsLinkService")
	private CmsLinkService cmsLinkService;

	@Resource(name = "indexService")
	private IndexService indexService;

	/**************************** 用于用户组栏目设置管理 ************/
	@Override
	// @RemoteMethod
	public void addGroupChannel(int gid, int cid) {
		groupService.addGroupChannel(gid, cid);
	}

	@Override
	// @RemoteMethod
	public void deleteGroupChannel(int gid, int cid) {
		groupService.deleteGroupChannel(gid, cid);
	}
	/**************************** 用于用户组栏目设置管理 ************/

	/**************************** dwr附件信息处理是删除附件 ************/
	@Override
	// @RemoteMethod
	public void deleteAttach(int id) {
		attachmentService.delete(id);
	}

	@Override
	// @RemoteMethod
	public void updatePicPos(int id, int oldPos, int newPos) {
		indexPicService.updatePos(id, oldPos, newPos);
		indexService.generatebanner();
	}

	@Override
	// @RemoteMethod
	public void updateLinkPos(int id, int oldPos, int newPos) {
		cmsLinkService.updatePos(id, oldPos, newPos);
	}

	@Override
	public void updatePro(String proName, String proMessage, String proPar, int id) {
		attachmentService.updatePro(proName, proMessage, proPar, id);
	}

	@Override
	public void updateIndexImg(Integer id, Integer isIndex) {
		attachmentService.updateIndexImg(id, isIndex);
		indexService.generateBody();
	}

	@Override
	public void updatePic(Integer proTypeId, String attName, String picMessage, String proPar, int id) {
		attachmentService.updatePic(proTypeId, attName, picMessage, proPar, id);
	}

	@Override
	public void updateVideo(Integer proTypeId, String attName, String picMessage, int id) {
		attachmentService.updateVideo(proTypeId, attName, picMessage, id);
	}

	@Override
	public void delUnUseFiles(String fileName) {
		topicService.delUnUseFiles(fileName);
	}

	@Override
	public void removeSession(HttpSession session) {
		session.removeAttribute("loginUser");
		System.out.println("ss");
	}

	@Override
	public void delUnUseIndexFiles(String fileName) {
		indexPicService.delUnUseIndexFiles(fileName);
	}

	@Override
	public void updateProPos(int id, int oldPos, int newPos) {
		attachmentService.updateProPos(id, oldPos, newPos);
	}

	@Override
	public void updateVdoPos(int id, int oldPos, int newPos) {
		attachmentService.updateVdoPos(id, oldPos, newPos);
	}

}
